<template>
	<view>
		<cu-custom bgColor="bg-red" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">领取记录</block>
		</cu-custom>

		<view class="bg-red overflow padding-lg text-white  relative">
			<view class=" ">
				<text class="text-gray" style="color: rgba(255, 255, 255, 1);">累计领取金额</text>
				<text class="text-price text-xl text-white margin-left-sm">{{total}}</text>
			</view>
		</view>
		<view class="cu-list bg-white">
			<view class="flex space-between text-center padding-tb text-bold">
				<view class="flex-sub">领取时间</view>
				<view class="flex-sub">领取红包（元）</view>
				<view class="flex-sub">剩余额度（元）</view>
			</view>
			<block v-for="(item,index) in list" :key="index">
				<view class="flex space-between text-center padding-bottom align-center">
					<view class="flex-sub">{{$common.timeFormat(item.created_at)}}</view>
					<view class="flex-sub text-red text-bold">{{item.num}}</view>
					<view class="flex-sub text-bold">{{item.last_num}}</view>
				</view>
			</block>
		</view>

		<view class="cu-load margin-center" :class="loading?'loading':'over'"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				member: null,
				config: null,
				CLOUDPATH: this.$config.cloudPath,
				theme: this.$config.THEME(),
				TabCur: 0,
				list: [],
				hasMore: true,
				loading: false,
				page: 1,
				statistics: null,
				total: 0,
			}
		},
		onLoad(options) {
			// if (this.$common.loginAuth(true)) {
			// 	this.$common.getConfig().then((config) => {
			// 		this.config = config
			// 		this.getList()
			// 	})
			// 	this.$common.getMember().then((member) => {
			// 		this.member = member
			// 	})
			// }
			this.getList()
		},
		onShow() {},
		methods: {
			getList() {
				if (this.hasMore && !this.loading) {
					this.loading = true
					this.$http
						.get('red_enveloper_logs', {
							page: this.page
						})
						.then((response) => {
							this.total = response.data.data.total
							let list = this.list
							if (response.data.data.list.length > 0) {
								list = list.concat(response.data.data.list)
							} else {
								this.hasMore = false
							}
							this.list = list
							this.page += 1

							this.loading = false
							uni.hideLoading()
						})
						.catch((response) => {
							uni.hideLoading()
						})

				}
			}
		},
		onReachBottom() {
			this.getList()
		}
	}
</script>

<style>
	.txbtn {
		min-width: 160rpx;
	}

	.loglg {
		right: 0;
		top: 30rpx;
		border-radius: 30rpx 0 0 30rpx;
	}

	.loglg2 {
		right: 0;
		top: 100rpx;
		border-radius: 30rpx 0 0 30rpx;
	}
</style>
